package com.start.cms.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.start.cms.entity.StartArticleBrowseRecordsEntity;
import com.start.cms.mappers.StartArticleBrowseRecordsMapper;
import com.start.cms.service.StartArticleBrowseRecordsService;
import org.springframework.stereotype.Service;

@Service
public class StartArticleBrowseRecordsServiceImpl extends ServiceImpl<StartArticleBrowseRecordsMapper, StartArticleBrowseRecordsEntity> implements StartArticleBrowseRecordsService {
    @Override
    public StartArticleBrowseRecordsEntity getRecordByArticleIdAndUserId(String userId, String articleId) {
        LambdaQueryWrapper<StartArticleBrowseRecordsEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(StartArticleBrowseRecordsEntity::getUserId, userId);
        lambdaQueryWrapper.eq(StartArticleBrowseRecordsEntity::getArticleId, articleId);
        lambdaQueryWrapper.last(" limit 1");
        return getOne(lambdaQueryWrapper);
    }
}
